package com.nth.rooster.core.exception;

public class RoosterCoreException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	private NErrorCode nErrorCode;
	private Object[] params;

	/**
	 * This constructor will throw the exception.
	 */
	public RoosterCoreException() {
		super();
	}

	/**
	 * This constructor will except a message if any exception is thrown.
	 * 
	 * @param message
	 *            String
	 */

	public RoosterCoreException(String message) {
		super(message);
	}

	/**
	 * This constructor will except a Throwable cause if any exception is
	 * thrown.
	 * 
	 * @param cause
	 *            Throwable
	 */

	public RoosterCoreException(Throwable cause) {
		super(cause);
	}

	/**
	 * This constructor will except a message and a cause if any exception is
	 * thrown.
	 * 
	 * @param message
	 *            String
	 * 
	 * @param cause
	 *            Throwable
	 */
	public RoosterCoreException(String message, Throwable cause) {
		super(message, cause);
	}

	/**
	 * Constructor with NErrorCode params.
	 * 
	 * @param nErrorCode
	 *            NErrorCode
	 * 
	 */
	public RoosterCoreException(NErrorCode nErrorCode) {
		this.nErrorCode = nErrorCode;
	}

	/**
	 * Constructor with NErrorCode and Object Params.
	 * 
	 * @param nErrorCode
	 *            NErrorCode, args Object...
	 * 
	 */
	public RoosterCoreException(NErrorCode nErrorCode, Object... args) {
		this.nErrorCode = nErrorCode;

		params = new Object[args.length];
		int count = 0;
		for (Object param : args) {
			params[count++] = param;
		}
	}

	/**
	 * Constructor with Throwable, NErrorCode and Object Params.
	 * 
	 * @param cause
	 *            Throwable
	 * @param nErrorCode
	 *            NErrorCode
	 * @param args
	 *            Object...
	 */
	public RoosterCoreException(Throwable cause, NErrorCode nErrorCode,
			Object... args) {
		super(cause);

		this.nErrorCode = nErrorCode;

		params = new Object[args.length];
		int count = 0;
		for (Object param : args) {
			params[count++] = param;
		}

	}

	/**
	 * This method returns params of object.
	 * 
	 * @return Object[]
	 * 
	 */
	public final Object[] getParams() {
		return params!=null? params.clone() : null;
	}

	/**
	 * This method returns NErrorCode.
	 * 
	 * @return NErrorCode
	 * 
	 */
	public NErrorCode getNErrorCode() {
		return nErrorCode;
	}

}
